<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>

      let result = {};
      result[(result["a"] = "b")] = "2";
      console.log(result);
      const proto = {
        foo: "hello",
      };
      let obj = {
        name: "121",
        l: "x",
      };
      proto.constructor = { name: "12" };
      Object.setPrototypeOf(obj, proto);
      console.log(obj.__proto__);
      console.log(proto);
      console.log(obj.constructor);

      function Person() {
        this.name = "2";
      }
      Person.prototype.cl = "3";
      let a = new Person();
      a.st = "22";
      let xdj = new Person();
      console.log(Object.getPrototypeOf(xdj));
      Object.defineProperty(a, "name", {
        enumerable: false,
        configurable: true,
      });
      for (let i in a) {
        console.log(i);
      }
      console.log(JSON.stringify(a));

      let b = { name: "xdj" };

      let bcopy = {
        age: 2,
      };
      Object.defineProperty(bcopy, "age", {
        enumerable: false,
      });
      console.log(Object.keys(bcopy));
      console.log(Object.getOwnPropertyNames(bcopy));
      console.log(Reflect.ownKeys(bcopy));
      Object.assign(b, bcopy);
      console.log(b, bcopy);

      let art1 = [12, 33, 44];
      let art2 = [55];
      Object.assign(art1, art2);
      console.log(art1);

      let proxyObj = {
        name: 2,
      };
      let proxyObj1 = new Proxy(proxyObj, {
        get: function (target, propKey, receiver) {
          console.log(target, propKey, receiver, "get");
          return 5;
        },
        set: function (target, propKey, value, receiver) {
          console.log(target, propKey, value, receiver, "set");
        },
      });
      console.log(proxyObj1.name);
      console.log(proxyObj.name);

      // generator
      var flat = function* (a) {
        var length = a.length;
        for (var i = 0; i <script length; i++) {
          var item = a[i];
          if (typeof item !== "number") {
            yield* flat(item);
          } else {
            yield item;
          }
        }
      };
      //generator内置方法
      //  Symbol.toStringTag：function(){return 'Generator'}
      console.log(Object.prototype.toString.call(flat([2, 3]))); //[object Generator]
      console.log(flat([2, 3])[Symbol.iterator]());
    </script>
  </body>
</html>
